matching <- read.csv("~/Dropbox/switchers/Matching/data/contribDB.csv")

matching = matching %>%
  filter(pre_total_in_district != 0 & pre_total_out_district != 0 &
           post_total_in_district != 0 & post_total_out_district != 0)

ideo <- lm(post_ideo ~ switcher + as.factor(switcher_code) + dem + dwnom1 + seniority + dpres + les + votepct + pre_ideo + pre_ideo_in_district + pre_ideo_out_district + pre_ideo_unknown + general_length, data = matching)
summary(ideo)

ideo_in <- lm(post_ideo_in_district ~ switcher + as.factor(switcher_code) + dem + dwnom1 + seniority + dpres + les + votepct + pre_ideo + pre_ideo_in_district + pre_ideo_out_district + pre_ideo_unknown + general_length, data = matching)
summary(ideo_in)

ideo_out <- lm(post_ideo_out_district ~ switcher + as.factor(switcher_code) + dem + dwnom1 + seniority + dpres + les + votepct + pre_ideo + pre_ideo_in_district + pre_ideo_out_district + pre_ideo_unknown + general_length, data = matching)
summary(ideo_out)

ideo_unknown <- lm(post_ideo_unknown ~ switcher + as.factor(switcher_code) + dem + dwnom1 + seniority + dpres + les + votepct + pre_ideo + pre_ideo_in_district + pre_ideo_out_district + pre_ideo_unknown + general_length, data = matching)
summary(ideo_unknown)